﻿/*
* ============================================================================
* GNU Lesser General Public License
* ============================================================================
*
* BYDAN - Free Java BYDAN library.
* Copyright (C) 2008 
* 
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
* 
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
* Lesser General Public License for more details.
* 
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307, USA.
* 
* BYDAN Corporation
*/
package ByDan.AulaVirtual.Business.Entities;

import java.util.ArrayList;
import ByDan.Framework.AulaVirtual.Business.Entities.GeneralEntity;
import ByDan.Framework.AulaVirtual.Business.Entities.Mensajes;
import ByDan.Framework.AulaVirtual.Utils.ParameterDbType;
import ByDan.Framework.AulaVirtual.Utils.ParameterType;
import ByDan.Framework.AulaVirtual.Utils.ParametersMaintenance;
import ByDan.Framework.AulaVirtual.Utils.ParameterMaintenance;
import ByDan.Framework.AulaVirtual.Utils.ParameterValue;
import ByDan.Framework.AulaVirtual.Utils.ParametersType;
import java.sql.*;

public class CatalogoUrl extends GeneralEntity
{
	static  String strTableName="CatalogoUrl";
		
	public static String getStrTableName() 
	{
		return strTableName;
	}

	public static void setStrTableName(String strTableName) 
	{
		CatalogoUrl.strTableName = strTableName;
	}
	
	public static String getColumnNameId()
	{
		return "id";
	}
	
	public CatalogoUrl catalogourlOriginal;
	
	public CatalogoUrl getCatalogoUrlOriginal()
	{
		return catalogourlOriginal;
	}
	
	public  void  setCatalogoUrlOriginal(CatalogoUrl catalogourl)
	{
		try
		{
			catalogourlOriginal=catalogourl;
		}
		catch(Exception ex)
		{
			;
		}
	}
	
	
	
	
	TipoUrl relationship_tipourl;
	 
	
	public TipoUrl getRelationship_TipoUrl()
	{
		return relationship_tipourl;
	}

	
	
	public  void  setRelationship_TipoUrl(TipoUrl tipourl)
	{
		try
		{
			relationship_tipourl=tipourl;
		}
		catch(Exception ex)
		{
			;
		}
	}


	
	
	ArrayList<Pagina> relationship_paginas;
	ArrayList<CatalogoUrlPagina> relationship_catalogourlpaginas;
	
	
	public ArrayList<Pagina> getRelationship_paginas()
	{
		return relationship_paginas;
	}

	public ArrayList<CatalogoUrlPagina> getRelationship_catalogourlpaginas()
	{
		return relationship_catalogourlpaginas;
	}

	
	
	public  void  setRelationship_Pagina(ArrayList<Pagina> paginas)
	{
		try
		{
			this.relationship_paginas=paginas;
		}
		catch(Exception ex)
		{
			;
		}
	}

	public  void  setRelationship_CatalogoUrlPagina(ArrayList<CatalogoUrlPagina> catalogourlpaginas)
	{
		try
		{
			this.relationship_catalogourlpaginas=catalogourlpaginas;
		}
		catch(Exception ex)
		{
			;
		}
	}

	
	private static Boolean blnDeleteCascade=false;
	private static String QueryInsert="insert into aulavirtualme_dbo.CatalogoUrl set IDTIPOURL=?,ISACTIVE=?,ISEXPIRED=?,VERSIONROW=CURRENT_TIMESTAMP,CODIGO=?,NOMBRE=?,HTMLINICIAL=?,HTMLFINAL=?,CSSINICIAL=?,CSSFINAL=?,XMLJASPERINICIAL=?,XMLJASPERFINAL=?,PATHICONO=?";
	private static String QueryUpdate="update aulavirtualme_dbo.CatalogoUrl set IDTIPOURL=?,ISACTIVE=?,ISEXPIRED=?,VERSIONROW=CURRENT_TIMESTAMP,CODIGO=?,NOMBRE=?,HTMLINICIAL=?,HTMLFINAL=?,CSSINICIAL=?,CSSFINAL=?,XMLJASPERINICIAL=?,XMLJASPERFINAL=?,PATHICONO=? where id=? AND versionRow=?";
	private static String QueryDelete="delete from aulavirtualme_dbo.CatalogoUrl where id=?";
	public static String QuerySelect="select aulavirtualme_dbo.CatalogoUrl.id,aulavirtualme_dbo.CatalogoUrl.IDTIPOURL,aulavirtualme_dbo.CatalogoUrl.isActive,aulavirtualme_dbo.CatalogoUrl.isExpired,aulavirtualme_dbo.CatalogoUrl.versionRow,aulavirtualme_dbo.CatalogoUrl.CODIGO,aulavirtualme_dbo.CatalogoUrl.NOMBRE,aulavirtualme_dbo.CatalogoUrl.HTMLINICIAL,aulavirtualme_dbo.CatalogoUrl.HTMLFINAL,aulavirtualme_dbo.CatalogoUrl.CSSINICIAL,aulavirtualme_dbo.CatalogoUrl.CSSFINAL,aulavirtualme_dbo.CatalogoUrl.XMLJASPERINICIAL,aulavirtualme_dbo.CatalogoUrl.XMLJASPERFINAL,aulavirtualme_dbo.CatalogoUrl.PATHICONO from aulavirtualme_dbo.CatalogoUrl";
	 
	Long field_bigIdTipoUrl;
	String field_strCodigo;
	String field_strNombre;
	String field_strHtmlinicial;
	String field_strHtmlfinal;
	String field_strCssinicial;
	String field_strCssfinal;
	String field_strXmljasperinicial;
	String field_strXmljasperfinal;
	String field_strPathicono;
				
	public CatalogoUrl ()
    {
		super();		
 		field_bigIdTipoUrl=-1L;
 		field_strCodigo="";
 		field_strNombre="";
 		field_strHtmlinicial=null;
 		field_strHtmlfinal=null;
 		field_strCssinicial=null;
 		field_strCssfinal=null;
 		field_strXmljasperinicial=null;
 		field_strXmljasperfinal=null;
 		field_strPathicono=null;
		
		
		relationship_tipourl=new TipoUrl();
		
		
		relationship_paginas=new ArrayList<Pagina>();
		relationship_catalogourlpaginas=new ArrayList<CatalogoUrlPagina>();
		
		super.setQueryInsert(QueryInsert);
		super.setQueryUpdate(QueryUpdate);
		super.setQueryDelete(QueryDelete);
		super.setQuerySelect(QuerySelect);
		
    } 
	
	public static Boolean getBlnDeleteCascade() 
	{
		return blnDeleteCascade;
	}

	public static void setBlnDeleteCascade(Boolean blnDeleteCascade) 
	{
		CatalogoUrl.blnDeleteCascade = blnDeleteCascade;
	}
	
	public static String getTableName()
    {
         return "aulavirtualme_dbo.CatalogoUrl";
    }
	
    
	public static String getColumnNameidTipoUrl()
	{
		return "idTipoUrl";
	}
    
	public static String getColumnNameCodigo()
	{
		return "Codigo";
	}
    
	public static String getColumnNameNombre()
	{
		return "Nombre";
	}
    
	public static String getColumnNameHtmlInicial()
	{
		return "HtmlInicial";
	}
    
	public static String getColumnNameHtmlFinal()
	{
		return "HtmlFinal";
	}
    
	public static String getColumnNameCssInicial()
	{
		return "CssInicial";
	}
    
	public static String getColumnNameCssFinal()
	{
		return "CssFinal";
	}
    
	public static String getColumnNameXmlJasperInicial()
	{
		return "XmlJasperInicial";
	}
    
	public static String getColumnNameXmlJasperFinal()
	{
		return "XmlJasperFinal";
	}
    
	public static String getColumnNamePathIcono()
	{
		return "PathIcono";
	}
     
    
	public Long getField_bigIdTipoUrl()
	{
		return field_bigIdTipoUrl;
	}
    
	public String getField_strCodigo()
	{
		return field_strCodigo;
	}
    
	public String getField_strNombre()
	{
		return field_strNombre;
	}
    
	public String getField_strHtmlinicial()
	{
		return field_strHtmlinicial;
	}
    
	public String getField_strHtmlfinal()
	{
		return field_strHtmlfinal;
	}
    
	public String getField_strCssinicial()
	{
		return field_strCssinicial;
	}
    
	public String getField_strCssfinal()
	{
		return field_strCssfinal;
	}
    
	public String getField_strXmljasperinicial()
	{
		return field_strXmljasperinicial;
	}
    
	public String getField_strXmljasperfinal()
	{
		return field_strXmljasperfinal;
	}
    
	public String getField_strPathicono()
	{
		return field_strPathicono;
	}
	
    
	public void setField_bigIdTipoUrl(Long newField_bigIdTipoUrl)throws Exception
	{
		try
		{
			if(this.field_bigIdTipoUrl!=newField_bigIdTipoUrl)
			{
				if(newField_bigIdTipoUrl==null)
				{
					throw new Exception(this.getTableName()+":"+ Mensajes.getMensajeExcepcionValorNulo()+" en columna "+CatalogoUrl.getColumnNameidTipoUrl());
				}

				this.field_bigIdTipoUrl=newField_bigIdTipoUrl;
				this.setIsChanged(true);
			}
		}
		catch(Exception ex)
		{
			throw ex;
		}
	}
    
	public void setField_strCodigo(String newField_strCodigo)throws Exception
	{
		try
		{
			if(this.field_strCodigo!=newField_strCodigo)
			{
				if(newField_strCodigo==null)
				{
					throw new Exception(this.getTableName()+":"+ Mensajes.getMensajeExcepcionValorNulo()+" en columna "+CatalogoUrl.getColumnNameCodigo());
				}

				this.field_strCodigo=newField_strCodigo;
				this.setIsChanged(true);
			}
		}
		catch(Exception ex)
		{
			throw ex;
		}
	}
    
	public void setField_strNombre(String newField_strNombre)throws Exception
	{
		try
		{
			if(this.field_strNombre!=newField_strNombre)
			{
				if(newField_strNombre==null)
				{
					throw new Exception(this.getTableName()+":"+ Mensajes.getMensajeExcepcionValorNulo()+" en columna "+CatalogoUrl.getColumnNameNombre());
				}

				this.field_strNombre=newField_strNombre;
				this.setIsChanged(true);
			}
		}
		catch(Exception ex)
		{
			throw ex;
		}
	}
    
	public void setField_strHtmlinicial(String newField_strHtmlinicial)
	{
		if(this.field_strHtmlinicial!=newField_strHtmlinicial)
		{
			this.field_strHtmlinicial=newField_strHtmlinicial;
			this.setIsChanged(true);
		}
	}
    
	public void setField_strHtmlfinal(String newField_strHtmlfinal)
	{
		if(this.field_strHtmlfinal!=newField_strHtmlfinal)
		{
			this.field_strHtmlfinal=newField_strHtmlfinal;
			this.setIsChanged(true);
		}
	}
    
	public void setField_strCssinicial(String newField_strCssinicial)
	{
		if(this.field_strCssinicial!=newField_strCssinicial)
		{
			this.field_strCssinicial=newField_strCssinicial;
			this.setIsChanged(true);
		}
	}
    
	public void setField_strCssfinal(String newField_strCssfinal)
	{
		if(this.field_strCssfinal!=newField_strCssfinal)
		{
			this.field_strCssfinal=newField_strCssfinal;
			this.setIsChanged(true);
		}
	}
    
	public void setField_strXmljasperinicial(String newField_strXmljasperinicial)
	{
		if(this.field_strXmljasperinicial!=newField_strXmljasperinicial)
		{
			this.field_strXmljasperinicial=newField_strXmljasperinicial;
			this.setIsChanged(true);
		}
	}
    
	public void setField_strXmljasperfinal(String newField_strXmljasperfinal)
	{
		if(this.field_strXmljasperfinal!=newField_strXmljasperfinal)
		{
			this.field_strXmljasperfinal=newField_strXmljasperfinal;
			this.setIsChanged(true);
		}
	}
    
	public void setField_strPathicono(String newField_strPathicono)
	{
		if(this.field_strPathicono!=newField_strPathicono)
		{
			this.field_strPathicono=newField_strPathicono;
			this.setIsChanged(true);
		}
	}
		
	public  void BuildParametersMaintenance(ParameterDbType newDbType,ParametersType parametersType) throws Exception
	{
		try
		{
			ParametersMaintenance parametersMaintenance=super.getParametersMaintenance();		
			ArrayList<ParameterMaintenance> parametersTemp=new ArrayList<ParameterMaintenance>();
			ParameterMaintenance parameterMaintenance;
			ParameterValue<Long> parameterMaintenanceValueId;
			
				if(!parametersType.equals(ParametersType.DELETE))
				{		
					parameterMaintenance=new ParameterMaintenance();
					parameterMaintenance.setOrder(1);		
					parameterMaintenance.setParameterMaintenanceType(ParameterType.LONG);
					ParameterValue<Long> parameterMaintenanceValueIdTipoUrl=new ParameterValue<Long>();
					parameterMaintenanceValueIdTipoUrl.setValue(this.getField_bigIdTipoUrl());
					parameterMaintenance.setParameterMaintenanceValue(parameterMaintenanceValueIdTipoUrl);
					parametersTemp.add(parameterMaintenance);
					
					parameterMaintenance=new ParameterMaintenance();
					parameterMaintenance.setOrder(2);		
					parameterMaintenance.setParameterMaintenanceType(ParameterType.BOOLEAN);
					ParameterValue<Boolean> parameterMaintenanceValueIsactive=new ParameterValue<Boolean>();
					parameterMaintenanceValueIsactive.setValue(this.getIsActive());
					parameterMaintenance.setParameterMaintenanceValue(parameterMaintenanceValueIsactive);
					parametersTemp.add(parameterMaintenance);
					
					parameterMaintenance=new ParameterMaintenance();
					parameterMaintenance.setOrder(3);		
					parameterMaintenance.setParameterMaintenanceType(ParameterType.BOOLEAN);
					ParameterValue<Boolean> parameterMaintenanceValueIsexpired=new ParameterValue<Boolean>();
					parameterMaintenanceValueIsexpired.setValue(this.getIsExpired());
					parameterMaintenance.setParameterMaintenanceValue(parameterMaintenanceValueIsexpired);
					parametersTemp.add(parameterMaintenance);
					
					parameterMaintenance=new ParameterMaintenance();
					parameterMaintenance.setOrder(4);		
					parameterMaintenance.setParameterMaintenanceType(ParameterType.STRING);
					ParameterValue<String> parameterMaintenanceValueCodigo=new ParameterValue<String>();
					parameterMaintenanceValueCodigo.setValue(this.getField_strCodigo());
					parameterMaintenance.setParameterMaintenanceValue(parameterMaintenanceValueCodigo);
					parametersTemp.add(parameterMaintenance);
					
					parameterMaintenance=new ParameterMaintenance();
					parameterMaintenance.setOrder(5);		
					parameterMaintenance.setParameterMaintenanceType(ParameterType.STRING);
					ParameterValue<String> parameterMaintenanceValueNombre=new ParameterValue<String>();
					parameterMaintenanceValueNombre.setValue(this.getField_strNombre());
					parameterMaintenance.setParameterMaintenanceValue(parameterMaintenanceValueNombre);
					parametersTemp.add(parameterMaintenance);
					
					parameterMaintenance=new ParameterMaintenance();
					parameterMaintenance.setOrder(6);		
					parameterMaintenance.setParameterMaintenanceType(ParameterType.STRING);
					ParameterValue<String> parameterMaintenanceValueHtmlinicial=new ParameterValue<String>();
					parameterMaintenanceValueHtmlinicial.setValue(this.getField_strHtmlinicial());
					parameterMaintenance.setParameterMaintenanceValue(parameterMaintenanceValueHtmlinicial);
					parametersTemp.add(parameterMaintenance);
					
					parameterMaintenance=new ParameterMaintenance();
					parameterMaintenance.setOrder(7);		
					parameterMaintenance.setParameterMaintenanceType(ParameterType.STRING);
					ParameterValue<String> parameterMaintenanceValueHtmlfinal=new ParameterValue<String>();
					parameterMaintenanceValueHtmlfinal.setValue(this.getField_strHtmlfinal());
					parameterMaintenance.setParameterMaintenanceValue(parameterMaintenanceValueHtmlfinal);
					parametersTemp.add(parameterMaintenance);
					
					parameterMaintenance=new ParameterMaintenance();
					parameterMaintenance.setOrder(8);		
					parameterMaintenance.setParameterMaintenanceType(ParameterType.STRING);
					ParameterValue<String> parameterMaintenanceValueCssinicial=new ParameterValue<String>();
					parameterMaintenanceValueCssinicial.setValue(this.getField_strCssinicial());
					parameterMaintenance.setParameterMaintenanceValue(parameterMaintenanceValueCssinicial);
					parametersTemp.add(parameterMaintenance);
					
					parameterMaintenance=new ParameterMaintenance();
					parameterMaintenance.setOrder(9);		
					parameterMaintenance.setParameterMaintenanceType(ParameterType.STRING);
					ParameterValue<String> parameterMaintenanceValueCssfinal=new ParameterValue<String>();
					parameterMaintenanceValueCssfinal.setValue(this.getField_strCssfinal());
					parameterMaintenance.setParameterMaintenanceValue(parameterMaintenanceValueCssfinal);
					parametersTemp.add(parameterMaintenance);
					
					parameterMaintenance=new ParameterMaintenance();
					parameterMaintenance.setOrder(10);		
					parameterMaintenance.setParameterMaintenanceType(ParameterType.STRING);
					ParameterValue<String> parameterMaintenanceValueXmljasperinicial=new ParameterValue<String>();
					parameterMaintenanceValueXmljasperinicial.setValue(this.getField_strXmljasperinicial());
					parameterMaintenance.setParameterMaintenanceValue(parameterMaintenanceValueXmljasperinicial);
					parametersTemp.add(parameterMaintenance);
					
					parameterMaintenance=new ParameterMaintenance();
					parameterMaintenance.setOrder(11);		
					parameterMaintenance.setParameterMaintenanceType(ParameterType.STRING);
					ParameterValue<String> parameterMaintenanceValueXmljasperfinal=new ParameterValue<String>();
					parameterMaintenanceValueXmljasperfinal.setValue(this.getField_strXmljasperfinal());
					parameterMaintenance.setParameterMaintenanceValue(parameterMaintenanceValueXmljasperfinal);
					parametersTemp.add(parameterMaintenance);
					
					parameterMaintenance=new ParameterMaintenance();
					parameterMaintenance.setOrder(12);		
					parameterMaintenance.setParameterMaintenanceType(ParameterType.STRING);
					ParameterValue<String> parameterMaintenanceValuePathicono=new ParameterValue<String>();
					parameterMaintenanceValuePathicono.setValue(this.getField_strPathicono());
					parameterMaintenance.setParameterMaintenanceValue(parameterMaintenanceValuePathicono);
					parametersTemp.add(parameterMaintenance);
					
						if(parametersType.equals(ParametersType.UPDATE))
						{					
							parameterMaintenance=new ParameterMaintenance();
							parameterMaintenance.setOrder(13);
							parameterMaintenance.setParameterMaintenanceType(ParameterType.LONG);
							parameterMaintenanceValueId=new ParameterValue<Long>();
							parameterMaintenanceValueId.setValue(this.getId());
							parameterMaintenance.setParameterMaintenanceValue(parameterMaintenanceValueId);		
							parametersTemp.add(parameterMaintenance);
							
							parameterMaintenance=new ParameterMaintenance();
							parameterMaintenance.setOrder(14);
							parameterMaintenance.setParameterMaintenanceType(ParameterType.TIMESTAMP);
							ParameterValue<Timestamp> parameterMaintenanceValueVersionRow=new ParameterValue<Timestamp>();
							parameterMaintenanceValueVersionRow.setValue(this.getVersionRow());
							parameterMaintenance.setParameterMaintenanceValue(parameterMaintenanceValueVersionRow);		
							parametersTemp.add(parameterMaintenance);					
						}
				}
				else
				{
					parameterMaintenance=new ParameterMaintenance();
					parameterMaintenance.setOrder(1);
					parameterMaintenance.setParameterMaintenanceType(ParameterType.LONG);
					parameterMaintenanceValueId=new ParameterValue<Long>();
					parameterMaintenanceValueId.setValue(this.getId());
					parameterMaintenance.setParameterMaintenanceValue(parameterMaintenanceValueId);		
					parametersTemp.add(parameterMaintenance);
				}
			
			parametersMaintenance= new ParametersMaintenance();
			parametersMaintenance.setDbType(newDbType);
			parametersMaintenance.setParametersMaintenance(parametersTemp);
			super.setParametersMaintenance(parametersMaintenance);		
		}
		catch(Exception ex)
		{
			throw ex;
		}
	}
}
